package my.jieh.tips.util.collection;

import java.util.SortedSet;
import java.util.TreeSet;

/**
 * <p>Title: Core Java Technologies Tech Tips</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: Blueimp</p>
 * @author jieh
 * @version 1.0
 */

public class SetDemo3 {

  static final int MIN = -5;
  static final int MAX = 5;
  static void f(int a, int b) {
    System.out.println(a + " " + b);
  }

  public static void main(String args[]) {
    /*
         int x = 10;
         x = x + (x = 5);
         System.out.println("x="+x);
     */
    int x = 10;
    f(x, x = 5);

    // create a SortedSet with
    // odd MIN-MAX Integer values

    SortedSet set = new TreeSet();
    for (int i = MIN; i <= MAX; i += 2) {
      set.add(new Integer(i));
    }
    System.out.println("set = " + set);

    // create a subset from 0 (inclusive)
    // to MAX (exclusive)

    SortedSet subset =
        set.subSet(
        new Integer(0), new Integer(MAX));
    System.out.println("subset = " + subset);

    // add a new element to the subset

    subset.add(new Integer(0));
    System.out.println(
        "set after add = " + set);
  }
}